{{left_sidebar_enabled,right_sidebar_enabled=True,False}}
{{extend 'layout.html'}}

<table id='scope' class='category'>
 <tbody>
<tr>
<th>Category</th>
<td>{{=quest['category']}}</td>
<th>Scope</th>
<td>{{=quest['activescope']}}</td>
<th>Active Area</th>
<td>{{=quest['scopetext']}}</td>
</tr>
 </tbody>
</table>


<table id='question' class='question'>
<tbody>
<tr>
<th>
{{if quest['qtype']=='action':}}
Action
{{else:}}
Question
{{pass}}
</th>
<td>
{{=MARKMIN(quest['questiontext'])}}</p>
</td>
</tr>
</tbody>
</table>


<table id='TabAnswers' class='answers'>
 <tbody>
<tr>
<td><input type="radio" name="ans" value="0" onchange="showansValue(this.value)"></td>
<td>Pass</td>
</tr>
{{anslist = quest['answers']
for k in xrange(1, quest['numanswers']+1):
}}
<tr>
<td><input type="radio" name="ans" value="{{=k}}" onchange="showansValue(this.value)" ></td>
<td>{{=anslist[k-1]}}</td>
</tr>
{{pass}}
 </tbody>
</table>

{{=form2}}



{{block left_sidebar}}

{{include 'newleftside.html'}}

{{end}}


<script>
function showurgValue(newValue)
{
	document.getElementById("userquestion_urgency").value=newValue;
}

function showansValue(newValue)

{
	document.getElementById("userquestion_answer").value=newValue;
//document.getElementById("userquestion_urgency").innerHTML=newValue;

}

function showimpValue(newValue)
{
	document.getElementById("userquestion_importance").value=newValue;
//document.getElementById("userquestion_urgency").innerHTML=newValue;
}

function showcountryValue(newValue)
{
	document.getElementById("userquestion_country").value=newValue;
    jQuery('#subdivopt').empty();
    ajax('{{=URL('submit','subdivn')}}', ['country'], 'subdivopt');
    document.getElementById("userquestion_subdivision").value="Unspecified";
}

function showsubdivValue(newValue)
{
	document.getElementById("userquestion_subdivision").value=newValue;
}

jQuery(document).ready(function(){
    jQuery('#userquestion_urgency__row .w2p_fc').html('<input id="urgslide" type = "range" name="urgslider"  min="0"    max="10" value="5" step="1" onchange="showurgValue(this.value)" />');
    jQuery('#userquestion_importance__row .w2p_fc').html('<input id="impslide" type = "range" name="impslider"  min="0" max="10" value="5" step="1" onchange="showimpValue(this.value)" />');
    jQuery('#userquestion_country__row .w2p_fc').html('<select id="countryopt" name="countryopt" onchange="showcountryValue(this.value)"> <option value="Unspecified">Unspecified</option>   </select>');

    jQuery('#userquestion_subdivision__row .w2p_fc').html('<select id="subdivopt" name="subdivopt" onchange="showsubdivValue(this.value)"> <option value="Unspecified">Unspecified</option> </select>');
    
   jQuery('#userquestion_answer__row').hide();
   jQuery('#userquestion_category__row').hide();
   jQuery('#userquestion_activescope__row').hide();
   jQuery('#userquestion_continent__row').hide();
   jQuery('#userquestion_country__row').hide();
   jQuery('#userquestion_subdivision__row').hide();

   jQuery('#userquestion_changecat').change(function(){
            jQuery('#userquestion_category__row').toggle();
    });
   jQuery('#userquestion_changescope').change(function(){
            jQuery('#userquestion_activescope__row').toggle();
            if(jQuery('#userquestion_activescope :selected').text()=='2 Continental')
            {jQuery('#userquestion_continent__row').show()
            jQuery('#userquestion_country__row').hide()
            jQuery('#userquestion_subdivision__row').hide()};
            jQuery('#countryopt').empty();
            ajax('{{=URL('submit','country')}}', ['continent'], 'countryopt');
            if(jQuery('#userquestion_activescope :selected').text()=='1 Global')
            {jQuery('#userquestion_continent__row').hide()
            jQuery('#userquestion_country__row').hide()
            jQuery('#userquestion_subdivision__row').hide()};
            if(jQuery('#userquestion_activescope :selected').text()=='3 National')
            {jQuery('#userquestion_continent__row').show();
            jQuery('#userquestion_country__row').show();
            jQuery('#userquestion_country__row .w2p_fw').hide();
            jQuery('#userquestion_subdivision__row').hide()};
            jQuery('#countryopt').empty();
            ajax('{{=URL('submit','country')}}', ['continent'], 'countryopt');
            if(jQuery('#userquestion_activescope :selected').text()=='4 Local')
            {jQuery('#userquestion_continent__row').show()
            jQuery('#userquestion_country__row').show()
            jQuery('#userquestion_subdivision__row').show()
            jQuery('#userquestion_country__row .w2p_fw').hide();
            jQuery('#userquestion_subdivision__row .w2p_fw').hide();
            jQuery('#subdivopt').empty();
            ajax('{{=URL('submit','subdivn')}}', ['country'], 'subdivopt');};

    });

    jQuery('#userquestion_activescope').change(function(){
            if(jQuery('#userquestion_activescope :selected').text()=='2 Continental')
            {jQuery('#userquestion_continent__row').show()
            jQuery('#userquestion_country__row').hide()
            jQuery('#userquestion_subdivision__row').hide()};
            if(jQuery('#userquestion_activescope :selected').text()=='1 Global')
            {jQuery('#userquestion_continent__row').hide()
            jQuery('#userquestion_country__row').hide()
            jQuery('#userquestion_subdivision__row').hide()};
            if(jQuery('#userquestion_activescope :selected').text()=='3 National')
            {jQuery('#userquestion_continent__row').show();
            jQuery('#userquestion_country__row').show();
            jQuery('#userquestion_country__row .w2p_fw').hide();
            jQuery('#userquestion_subdivision__row').hide()};
            if(jQuery('#userquestion_activescope :selected').text()=='4 Local')
            {jQuery('#userquestion_continent__row').show()
            jQuery('#userquestion_country__row').show()
            jQuery('#userquestion_subdivision__row').show()
            jQuery('#userquestion_country__row .w2p_fw').hide();
            jQuery('#userquestion_subdivision__row .w2p_fw').hide();};});

    jQuery('#userquestion_country').change(function(){
            jQuery('#subdivopt').empty();
            ajax('{{=URL('submit','subdivn')}}', ['country'], 'subdivopt');});

    jQuery('#userquestion_continent').change(function(){
            jQuery('#countryopt').empty();
            ajax('{{=URL('submit','country')}}', ['continent'], 'countryopt');});


}); 

</script>

